Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

239
Vistas
Why is my JSON object showing [Array] instead of the data in javascript after reformatting?

Currently I am trying to create a JSON object in java script which has an additional array containing all of the data that I currently posses:

src is a JSON object which before any code is run is equal to:

[
  {
    _id: new ObjectId("629ac43586b27bfd70337d06"),
    Title: 'Test Poll',
    Option: [ 'Test Option 1', 'Test Option 2', 'Test Option 3' ]
  },
  {
    _id: new ObjectId("629afc9286b27bfd70337d09"),
    Title: 'Test Poll 2',
    Option: [ 'Test Option 1' ]
  }
]

I need to reformat this object so that it is contained within a separate array which I am currently attempting to do with this line:

  var context = { poll:src };

This results in a reformatting of the JSON object which I do not understand, after running this code context contains:

  poll: [
    {
      _id: new ObjectId("629ac43586b27bfd70337d06"),
      Title: 'Test Poll',
      Option: [Array]
    },
    {
      _id: new ObjectId("629afc9286b27bfd70337d09"),
      Title: 'Test Poll 2',
      Option: [Array]
    }
  ]

It gets rid of the Option arrays and replaces them with [Array]. I need to keep these arrays and I am not sure what to change to fix this as I have tried looking elsewhere for answers. Does anyone have an idea of what is going on here?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Ok they are arrays I am just too new to realize that it would not print fully. I was attempting to use handlebars on these Option arrays to print the list and I was forgetting to use the implicit this for the variable name instead of just 'Option'.

Problem solved.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda